<template>
  <div class="transaction-record">
    <!-- 数据表 -->
    <div class="data-table">
      <el-table
        v-loading="loading"
        element-loading-text="拼命加载中..."
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(211, 215, 212, 0.5)"
        :data="tableData"
        stripe
        header-cell-class-name="headerStyle"
        style="width: 100%"
      >
        <el-table-column align="center" prop="user_name" label="操作员" width="120"></el-table-column>
        <el-table-column align="center" prop="ip" label="ip" width="200"></el-table-column>
        <el-table-column align="center" prop="platform_id" label="平台id"></el-table-column>
        <el-table-column align="center" prop="business" label="业务名称"></el-table-column>
        <el-table-column align="center" prop="table" label="操作表"></el-table-column>
        <el-table-column align="center" prop="create_time" label="操作时间"></el-table-column>
      </el-table>
      <!-- 分页 -->
      <pages
        :pages="searchForm"
        :total="total"
        @pageSizeChange="pageSizeChange"
        @pageChange="pageChange"
      ></pages>
    </div>
  </div>
</template>

<script>
import Pages from "@/components/PageBox.vue";
import { getLogList } from "./log.service.js";

export default {
  components: {
    Pages
  },
  data() {
    return {
      loading: false,
      searchForm: {
        page: 1,
        size: 10
      },
      tableData: [],
      total: 10
    };
  },
  mounted() {
    this.search();
  },
  methods: {
    async search() {
      this.loading = true;
      const res = await getLogList(this.searchForm);
      this.tableData = res.data.items || [];
      this.total = res.data.total;
      this.loading = false;
    },
    pageChange(val) {
      this.searchForm.page = val;
      this.search(val);
    },
    pageSizeChange(val) {
      this.searchForm.size = val;
      this.searchForm.page = 1;
      this.search();
    }
  }
};
</script>

<style lang="scss" scoped>
.transaction-record {
  position: relative;
  min-height: calc(100vh - 100px);

  .search-block {
    width: 100%;
    padding: 25px 30px;
    border-radius: 5px;
    background: #fff;
    box-shadow: rgba(0, 0, 0, 0.1) 0 0 15px;

    .item-msg {
      display: inline-block;
      margin-right: 20px;
      height: 60px;
      line-height: 60px;
      font-size: 1 size= "medium" 4;
      color: $admin_font_param;

      label {
        display: inline-block;
        min-width: 80px;
        text-align: right;
        margin-right: 10px;
      }

      .el-input {
        width: 150px;
      }

      .el-select {
        width: 150px;
      }

      .el-date-editor {
        width: 270px;
      }
    }

    .search-btn {
      margin-left: 30px;
    }

    .search-btn:nth-of-type(1) {
      margin-left: 50px;
    }
  }

  .data-table {
    padding-bottom: 20px;
    background: #fff;
    border-radius: 5px;
    margin-top: 30px;
    box-shadow: rgba(0, 0, 0, 0.1) 0 0 15px;
  }
}
</style>
